/*
ID: khymill1
PROG: fact4 
LANG: C++
*/
#include <string.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>
#include <limits.h>

using namespace std;

int main()
{
    ifstream fin("fact4.in");
    ofstream fout("fact4.out");
    int n;
    fin >> n;
    unsigned int a = 1;
    for (unsigned int i = 1; i <= n; i++) {
        if (a > INT_MAX/i) 
        a %= 100000;
        a *= i;
        int tmp = a%10;
        cout << i << " " << tmp <<  " " << a << endl;
        if (tmp == 0) a/= 10;
        cout << a << endl;
    }
    cout << a%10 << endl;
    return 0;
}                                          
